package com.wfm;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.PropertyNamingStrategy;
import com.alibaba.fastjson2.annotation.JSONType;
import lombok.Data;

import java.util.List;

public class Main {
    public static void main(String[] args) {
        String jsonString = "{\"name_abc\":1,\"sub\":[{\"age_abc\":1},{\"age_abc\":2}]}";
        Test test = JSON.parseObject(jsonString, Test.class);
        System.out.println(test);
        System.out.println(JSON.toJSONString(test));
    }

    @Data
    @JSONType(naming= PropertyNamingStrategy.SnakeCase)
    class Test{
        //        @JSONField(name = "name_abc")
        String nameAbc;
        List<Sub> sub;
    }

    @Data
    @JSONType(naming= PropertyNamingStrategy.SnakeCase)
    class Sub{
        String ageAbc;
    }
}
